package com.bdqn.jwt1.controller;

import com.bdqn.jwt1.entity.ResponseResult;
import com.bdqn.jwt1.entity.TUser;
import com.bdqn.jwt1.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TUserController {
    @Autowired
    private TUserService tUserService;

    @PreAuthorize("hasAnyRole('manager','admin')")
    @GetMapping("/users")
    public ResponseResult<TUser> findAllUsers() {
        ResponseResult sr = new ResponseResult();
        sr.setCode(200);
        sr.setFlag(true);
        sr.setData(tUserService.findAllUsers());
        return sr;
    }
}
